#!/bin/bash

#Usage: ./join_cluster.sh TARGETIP $ports

# localhost:port will be added to TARGET:7400

IP=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')

DEFAULT_PORT=7400

for port in "$@"
do
	if [[ "${port}" == "$1" ]]
	then
		TARGET=$1
	else
		./redis-trib.rb add-node ${IP}:${port} ${TARGET}:${DEFAULT_PORT}
	fi
done